package com.wteam.controller;


import com.wteam.PoJo.DTO.CartDTO;
import com.wteam.PoJo.DTO.PageQuery;
import com.wteam.PoJo.DTO.upCartDTO;
import com.wteam.PoJo.VO.CartVO;
import com.wteam.Service.ICartService;
import com.wteam.until.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 购物车表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-07-16
 */
@RestController
@RequestMapping("/cart")
@Api(tags = "购物车模块")
@Slf4j
public class CartController {
@Autowired
private ICartService iCartService;

    @ApiOperation(value = "添加购物车商品")
    @PutMapping("/addcart")
    public Result addcart(@RequestBody CartDTO cartDTO){
        return iCartService.addcart(cartDTO);
    }

    @ApiOperation(value = "批量删除购物车商品")
    @DeleteMapping("/deletecart")
    public Result deletecart(@RequestBody List<CartDTO> cartDTO){
log.info(cartDTO.toString());
        return iCartService.deletecart(cartDTO);
    }

    @ApiOperation(value = "展示购物车商品")
    @PutMapping("/cartshop")
    public Result<CartVO> cartshop(PageQuery pageQuery){
        return iCartService.cartshop(pageQuery);
    }

    @ApiOperation(value = "更改购物车数据")
    @PutMapping("/upcartshop")
    public Result upcartshop(@RequestBody List<upCartDTO> upCartDTO){
        return iCartService.upcartshop(upCartDTO);
    }

}
